<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/include/page.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>修改收货地址 - SXT商城</title>
		<%@ include file="/common/include/title.jsp"%>
		<link type="text/css" href="${rootpath }/css/my.css" rel="stylesheet">
		<link type="text/css" href="${rootpath }/css/list.css" rel="stylesheet">
	</head>
	<body>
		<div id="doc">
			<%@ include file="/common/include/header.jsp"%>
			<div id="s_bdw">
				<div id="s_bd">
					<div style="margin: 10px 0 0 0;"></div>
					<div class="breadcrumbs">
						<div class="f-l">
							<a href="#">首页</a><span>»</span><a href="#">我的SXT</a><span>»</span>资料修改
						</div>
					</div>
					<%@ include file="/common/include/left_header.jsp"%>
					<div class="f-r presonalinfo">
						<div class="dl_zc_title">
							<h2 class="f_l">更新收货地址</h2>
							<div class="rt_bg f_r"></div>
						</div>
						<div class="ddbox">
							<div class="dl-con cf" id="entry">
								<form id="formlogin" action="${rootpath }/head/users/addressUpdateSubmit.htm" method="post">
									<input type="hidden" name="uaid" value="${requestScope.usersAddress.id }"/>
									<input type="hidden" name="isDef" value="${requestScope.usersAddress.isDef }"/>
									<div class="form" style="width: 600px;">
										<div class="item">
											<span class="label">名称：</span>
											<div class="fl">
												<input type="text" name="name" class="text" value="${requestScope.usersAddress.name}"/>
											</div>
										</div>
										<!--item end-->
										<div class="item">
											<span class="label">收货人：</span>
											<div class="fl">
												<input type="text" name="contact" class="text" value="${requestScope.usersAddress.contact}"/>
											</div>
										</div>
										<!--item end-->
										<div class="item">
											<span class="label">手机号：</span>
											<div class="fl">
												<input type="text" name="phone" class="text" value="${requestScope.usersAddress.phone}"/>
											</div>
										</div>
										<!--item end-->
										<div class="item">
											<span class="label">地区:</span>
											<div class="fl">
												<span id="regionShow"></span>
												<input type="button" value="修改地区" onclick="return $('#regionDiv').show()"/>
											</div>
										</div>
										<!--item end-->
										<div class="item">
											<span class="label">地区:</span>
											<div class="fl">
												<input type="hidden" id="regionId" name="regionId" value="${requestScope.usersAddress.regionId}"/>
												<div id="regionDiv" style="display: none">
													<select id="regionId1" onchange="return selectRegionList('regionId1','regionId2','regionId')"></select>
													<select id="regionId2" onchange="return selectRegionList('regionId2','regionId3','regionId')"></select>
													<select id="regionId3" onchange="return selectRegionList('regionId3','regionId4','regionId')"></select>
												</div>
												<span class="clear"></span>
											</div>
										</div>
										<!--item end-->
										<div class="item">
											<span class="label">详细地址:</span>
											<div class="fl">
												<input type="text" name="address" class="text" value="${requestScope.usersAddress.address}"/>
											</div>
										</div>
										<!--item end-->
										<div class="item">
											<span class="label">邮编：</span>
											<div class="fl">
												<input type="text" name="zipCode" class="text" value="${requestScope.usersAddress.zipCode}"/>
											</div>
										</div>
										<div class="item">
											<span class="label">状态：</span>
											<div class="fl">
												<input type="radio" name="status" id="status1" value="1" checked="checked"/><label for="status1">启用</label>
												<input type="radio" name="status" id="status0" value="0"/><label for="status0">禁用</label>
											</div>
										</div>
										<div class="item">
											<span class="label">&nbsp;</span>
											<span class="error_info">
												${info }
											</span>
										</div>
										<!--item end-->
										<div class="item">
											<span class="label">&nbsp;</span>
											<input type="submit" id="loginsubmit" value="提交" tabindex="8"/>
										</div>
										<!--item end-->
									</div>
									<div class="clear"></div>
								</form>
							</div>
						</div>
					</div>
					<!--presonalinfo end-->
					<div class="clear"></div>
				</div>
				<!--s_bd end-->
			</div>
			<%@ include file="/common/include/footer.jsp"%>
		</div>
	</body>
</html>
<script type="text/javascript">
	/**
		查询地区列表
		页面一加载的时候,木有currSelectid
		regionId:目标存储结果的值
	*/
	function selectRegionList(currSelectid,tarSelectId,regionId)
	{
		/* 取得当前Select框的Id */
		var currSelect = $("#" + currSelectid) ;
		/* 0:表示取出所有的省份 */
		var parentId = "0"
		/* alert(currSelect.length); */
		if(currSelect.length == 1)
		{
			/* 表示取到数据 */
			parentId = currSelect.val();
		}
		
		$("#" + regionId).val(parentId)
		
		/* 找不到目标,就不再进行Ajax */
		if($("#" + tarSelectId).length == 0)
		{
			return ; 
		}
		$.post(
			"${rootpath}/outer/regionList.htm",
			"json={'version':'1','data':{'parentId':'"+ parentId +"'}}",
			function(data)
			{
				//alert(data.code)
				if(data.code == '0')
				{
					/* 拼装html;select框 */
					var sb = "<option value='0'>请选择</option>" ; 
					for(var i = 0 ; i < data.data.regionList.length ; i ++)
					{
						var region = data.data.regionList[i] ; 
						//sb += region.name + "---" ;
						sb += "<option value='"+ region.id +"'>"+ region.name +"</option>"
					}
					$("#" + tarSelectId).html(sb);
				}
			},
			"json"
		);
	}
	
	/* 一开始加载,为省份初始化 */
	selectRegionList("0","regionId1");
	
	$.post(
		"${rootpath}/outer/regionList.htm",
		"json={'version':'1','data':{'parentId':'${requestScope.usersAddress.regionId}'}}",
		function(data)
		{
			//alert(data.code)
			if(data.code == '0')
			{
				//alert(data.data.region.treeName);
				if(data.data.region != null)
				{
					$("#regionShow").html(data.data.region.treeName)
				}
			}
		},
		"json"
	);
</script>